package com.topteam.demo.controller

import javax.enterprise.inject.Model
import javax.inject.Inject
import com.topteam.demo.service.TodoService
import com.topteam.demo.domain.{User, Todo}
import java.util.UUID
import scala.beans.BeanProperty

/**
 * Created by thinkpad on 14-1-24.
 */
@Model
class TodoController extends Serializable {

  @Inject var todoService: TodoService = _
  @Inject
  @BeanProperty var todo: Todo = _
  @Inject
  @BeanProperty var user:User = _

  def save(): Unit = {
    todo.setId(UUID.randomUUID().toString)
    todoService.addNewTodo(todo,user)
  }
}
